<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="result"></div>
    <script>
        // isacc = "第一个值";
        // localStorage.setItem("a",isacc);    //设置为 "isacc"
        // var a = localStorage.getItem("b");
        // console.log(a);


        // var name1 = localStorage.a;
        // console.log(name1);
        // var name2 = localStorage['a']; 
        // console.log(name2);

        // sessionStorage



        // if (typeof (Storage) !== "undefined") {
        //     sessionStorage.setItem("lastname", "Smith");
        //     // 检索
        //     document.getElementById("result").innerText = sessionStorage.getItem(
        //         "lastname"
        //     );
        // } else {
        //     document.getElementById("result").innerText = "Sorry, your browser does not support Web Storage..."
        // }

        localStorage.setItem("x", 1);
        localStorage.getItem("x");

        // 枚举所有的名字
        for (var i = 0; i < localStorage.length; i++) {
            var name = localStorage.key(i);
            var value = localStorage.getItem(name);
        }
        console.log(localStorage.key(0));
        // localStorage.removeItem("x");
        // localStorage.clear();
        console.log(localStorage);




    </script>
</body>

</html>